package cn.zch.soft.service;
import cn.zch.soft.mapper.DeviceQrcodeImageMapper;
import cn.zch.soft.model.DeviceQrcodeImage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class DeviceQrcodeImageService {
  @Resource
  private DeviceQrcodeImageMapper deviceQrcodeImageMapper;
  public int deleteByPrimaryKey(Integer id) {
    return deviceQrcodeImageMapper.deleteByPrimaryKey(id);
  }
  public int insert(DeviceQrcodeImage record) {
    return deviceQrcodeImageMapper.insert(record);
  }
  public int insertSelective(DeviceQrcodeImage record) {
    return deviceQrcodeImageMapper.insertSelective(record);
  }
  public DeviceQrcodeImage selectByPrimaryKey(Integer id) {
    return deviceQrcodeImageMapper.selectByPrimaryKey(id);
  }
  public int updateByPrimaryKeySelective(DeviceQrcodeImage record) {
    return deviceQrcodeImageMapper.updateByPrimaryKeySelective(record);
  }
  public int updateByPrimaryKey(DeviceQrcodeImage record) {
    return deviceQrcodeImageMapper.updateByPrimaryKey(record);
  }
  public List<DeviceQrcodeImage> selectBydevice(Integer begindeviceNum, Integer enddeviceNum, int equalUrl) {
    String sql = "select * from  device_qrcode_image  where" + " equal_url =" + equalUrl;
    if (begindeviceNum != null && enddeviceNum != null) {
      sql += " and device_id between " + begindeviceNum + " and " + enddeviceNum;
    }
    else if (begindeviceNum != null) {
      sql += " and device_id=" + begindeviceNum;
    }
    else if (enddeviceNum != null) {
      sql += " and device_id=" + enddeviceNum;
    }
    sql += " ORDER BY device_id";
    return deviceQrcodeImageMapper.selectBydevice(sql);
  }
  public void deleteLIKEhttpurl(String sub) {
    String sql = "delete from device_qrcode_image where http_url like '%" + sub + "%'";
    deviceQrcodeImageMapper.deleteLIKEhttpurl(sql);
  }
  public List<DeviceQrcodeImage> selectAll() {
    return deviceQrcodeImageMapper.selectAll();
  }
}



